home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / irsim-ca.2 / irsim-ca / irsim-cap-9.2 / src / irsim / conn_list.c < prev    next >
C/C++ Source or Header  |  1994-07-20  |  4KB  |  140 lines

  1. /* 
  2.  *     ********************************************************************* 
  3.  *     * Copyright (C) 1988, 1990 Stanford University.                     * 
  4.  *     * Permission to use, copy, modify, and distribute this              * 
  5.  *     * software and its documentation for any purpose and without        * 
  6.  *     * fee is hereby granted, provided that the above copyright          * 
  7.  *     * notice appear in all copies.  Stanford University                 * 
  8.  *     * makes no representations about the suitability of this            * 
  9.  *     * software for any purpose.  It is provided "as is" without         * 
  10.  *     * express or implied warranty.  Export of this software outside     * 
  11.  *     * of the United States of America may require an export license.    * 
  12.  *     ********************************************************************* 
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include "defs.h"
  17. #include "net.h"
  18. #include "net_macros.h"
  19. #include "ASSERT.h"
  20. #include "globals.h"
  21.  
  22.  
  23. public
  24. #define    MAX_PARALLEL    30    /* this is probably sufficient per stage */
  25.  
  26. public    tptr  parallel_xtors[ MAX_PARALLEL ];
  27.  
  28. public
  29. #define    par_list( T )        ( parallel_xtors[ (T)->n_par ] )
  30.  
  31. #define    hash_terms( T )        ( (Ulong)((T)->source) ^ (Ulong)((T)->drain) )
  32.  
  33.  
  34. /*
  35.  * Build a linked-list of nodes (using nlink entry in Node structure)
  36.  * which are electrically connected to node 'n'.  No special order
  37.  * is required so tree walk is performed non-recursively by doing a
  38.  * breath-first traversal.  The value caches for each transistor we
  39.  * come across are reset here.  Loops are broken at an arbitrary point
  40.  * and parallel transistors are identified.
  41.  */
  42. public void BuildConnList( n )
  43.   register nptr  n;
  44.   {
  45.     register nptr  next, this, other;
  46.     register tptr  t;
  47.     register lptr  l;
  48.     int            n_par = 0;
  49.  
  50.     n->nflags &= ~VISITED;
  51.     withdriven = FALSE;
  52.  
  53.     next = this = n->nlink = n;
  54.     do
  55.       {
  56.     for( l = this->nterm; l != NULL; l = l->next )
  57.       {
  58.         t = l->xtor;
  59.         if( t->state == OFF )
  60.         continue;
  61.         if( t->tflags & CROSSED )    /* Each transistor is crossed twice */
  62.           {
  63.         t->tflags &= ~CROSSED;
  64.         continue;
  65.           }
  66.         t->scache.r = t->dcache.r = NULL;
  67.  
  68.         other = other_node( t, this );
  69.  
  70.         if( other->nflags & INPUT )
  71.           {
  72.         withdriven = TRUE;
  73.         continue;
  74.           }
  75.  
  76.         t->tflags |= CROSSED;        /* Crossing trans 1st time */
  77.  
  78.         if( other->nlink == NULL )        /* New node in this stage */
  79.           {
  80.         other->nflags &= ~VISITED;
  81.         other->nlink = n;
  82.         next->nlink = other;
  83.         next = other;
  84.         other->n.tran = t;        /* we reach other through t */
  85.           }
  86.         else if( model_num != LIN_MODEL )
  87.         continue;
  88.         else if( hash_terms( other->n.tran ) == hash_terms( t ) )
  89.           {                        /* parallel transistors */
  90.         register tptr  tran = other->n.tran;
  91.  
  92.         if( tran->tflags & PARALLEL )
  93.             t->dcache.t = par_list( tran );
  94.         else
  95.           {
  96.             if( n_par >= MAX_PARALLEL )
  97.               {
  98.             WarnTooManyParallel( this->nname, other->nname );
  99.             t->tflags |= PBROKEN;        /* simply ignore it */
  100.             continue;
  101.               }
  102.             tran->n_par = n_par++;
  103.             tran->tflags |= PARALLEL;
  104.           }
  105.         par_list( tran ) = t;
  106.         t->tflags |= PBROKEN;
  107.           }
  108.         else
  109.           {                    /* we have a loop, break it */
  110.         t->tflags |= BROKEN;
  111.           }
  112.       }
  113.       }
  114.     while( (this = this->nlink) != n );
  115.  
  116.     next->nlink = NULL;            /* terminate connection list */
  117.   }
  118.  
  119.  
  120. public void WarnTooManyParallel( s1, s2 )
  121.   char  *s1, *s2;
  122.   {
  123.     static  int  did_it = FALSE;
  124.  
  125.     if( did_it )
  126.     return;
  127.     lprintf( stderr,
  128.       "There are too many transistors in parallel (> %d)\n", MAX_PARALLEL );
  129.     lprintf( stderr,
  130.       "Simulation results may be inaccurate, to fix this you may have to\n" );
  131.     lprintf( stderr,
  132.       "increase this limit in '%s'.\n", __FILE__ );
  133.     lprintf( stderr,
  134.       "Note: This condition often occurs when Vdd or Gnd are not connected\n" );
  135.     lprintf( stderr,
  136.       "      to all cells.  Check the vicinity of the following 2 nodes:\n" );
  137.     lprintf( stderr, "      %s\n      %s\n", s1, s2 );
  138.     did_it = TRUE;
  139.   }
  140.